package main

import (
	"context"
	"git.900sui.cn/kc/base/utils"
	"git.900sui.cn/kc/kcgin"
	"git.900sui.cn/kc/kcgin/logs"
	"git.900sui.cn/kc/rabbitmq"
	"git.900sui.cn/kc/rpcinterface/client/order"
	"github.com/streadway/amqp"
	"strconv"
)

//同步身份卡折扣标识到卡包中
func main() {
	rpcOrder := new(order.CardPackage).Init()
	defer rpcOrder.Close()
	logs.Info("Environment Variable:MSF_ENV:", kcgin.KcConfig.RunMode)
	new(utils.KcLog).GetInstance(kcgin.AppConfig.String("order.log.updateIcardPackageSyncLogo"))

	err := rabbitmq.Rabbitmq.Consume(kcgin.AppConfig.String("order.queue.updateIcardPackageSyncLogo"), func(msg amqp.Delivery) {
		icardId, _ := strconv.Atoi(string(msg.Body))
		reply := false
		//同步身份卡折扣标识到身份卡包中
		if err:=rpcOrder.UpdateIcardPackageSyncLogo(context.Background(),&icardId,&reply);err!=nil{
			utils.Logerr.Printf("同步身份卡折扣标识到卡包中调用失败，icardId:%s, err:%s", icardId, err)
		}
	})

	if err != nil {
		utils.Logerr.Printf("同步身份卡折扣到卡包中任务错误, err: %s", err.Error())
	}
}
